﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClearingRestartingAutomaton.Base
{
    /// <summary>
    /// The structure WordTree describes the rooted tree of words obtained from the given 
    /// initial word placed at the root of the tree by applying the given set of instructions.
    /// Only one of the two possible ways how to apply instructions is used.
    /// </summary>
    [Serializable]
    public struct WordTree
    {
        #region Constructors

        /// <summary>
        /// Constructor of this structure.
        /// </summary>
        /// <param name="initialWord">The initial word placed at the root of the tree.</param>
        /// <param name="leftContext">The left context of the given initial word.</param>
        /// <param name="rightContext">The right context of the given initial word.</param>
        /// <param name="instructionUse">The way the instructions are used.</param>
        /// <param name="treeList">The list of all words in the tree.</param>
        /// <param name="treeSet">The set of all words in the tree.</param>
        /// <param name="treeSteps">The dictionary mapping each word in the tree to the InstructionStep structure which led to this word.</param>
        public WordTree(
            string initialWord,
            string leftContext,
            string rightContext,
            InstructionUse instructionUse,
            List<string> treeList,
            SortedDictionary<string, bool> treeSet,
            SortedDictionary<string, InstructionStep> treeSteps)
        {
            this.initialWord = initialWord;
            this.leftContext = leftContext;
            this.rightContext = rightContext;
            this.use = instructionUse;
            this.treeList = treeList;
            this.treeSet = treeSet;
            this.treeSteps = treeSteps;
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// The initial word placed at the root of the tree.
        /// </summary>
        public string InitialWord
        {
            get { return this.initialWord; }
        }

        /// <summary>
        /// The left context of the given initial word.
        /// </summary>
        public string LeftContext
        {
            get { return this.leftContext; }
        }

        /// <summary>
        /// The right context of the given initial word.
        /// </summary>
        public string RightContext
        {
            get { return this.rightContext; }
        }

        /// <summary>
        /// The way the instructions are used.
        /// </summary>
        public InstructionUse Use
        {
            get { return this.use; }
        }

        /// <summary>
        /// The list of all words in the tree.
        /// </summary>
        public List<string> TreeList
        {
            get { return this.treeList; }
        }

        /// <summary>
        /// The set of all words in the tree.
        /// </summary>
        public SortedDictionary<string, bool> TreeSet
        {
            get { return this.treeSet; }
        }

        /// <summary>
        /// The dictionary mapping each word in the tree to the InstructionStep structure which led to this word.
        /// </summary>
        public SortedDictionary<string, InstructionStep> TreeSteps
        {
            get { return this.treeSteps; }
        }

        #endregion

        #region Private Data Members

        private string initialWord;
        private string leftContext;
        private string rightContext;
        private InstructionUse use;
        private List<string> treeList;
        private SortedDictionary<string, bool> treeSet;
        private SortedDictionary<string, InstructionStep> treeSteps;

        #endregion
    }
}
